<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Core\Traits\Database\SchemaCommentTrait;

class CreateUrls extends Migration
{
    use SchemaCommentTrait;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('urls', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('记录ID');
            $table->string('url', 128)->comment('链接')->index();
            $table->text('extras_properties')->comment('链接其他属性值');
            $table->string('comment',100)->comment('备注说明');
            $table->string('hash')->comment('链接唯一hash')->unique();
            $table->string('app_name',100)->comment('应用名称')->default('qq_news')->index();
            $table->string('type')->comment('链接类型 enum[news,url,image,voice,video,doc,css,js,...]')->index();
            $table->string('crawler_id',100)->comment('爬取节点')->index();
            $table->dateTime('created_at')->nullable(false)->comment('创建时间');
            $table->dateTime('updated_at')->nullable(false)->comment('更新时间');
            $table->dateTime('deleted_at')->nullable(true)->comment('删除时间');
        });
        $this->comment('urls', 'url爬取记录表');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('urls');
    }
}
